<?php

use yii\helpers\Html;
use kartik\grid\GridView;
use yii\helpers\Url;
use common\models\meeting\Meeting;

/* @var $this yii\web\View */
/* @var $searchModel common\models\meeting\MeetingSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', '会议列表');
$this->params['breadcrumbs'][] = $this->title;
?>
<?php $this->beginBlock('siderbar'); ?>
<?= $this->render('//layouts/cms-menu') ?>
<?php $this->endBlock(); ?>
<div class="meeting-index">

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a(Yii::t('app', '新增'), ['create'], ['class' => 'btn btn-success']) ?>
		<button class="btn btn-warning" id="stop" type="button">关闭报名</button>
        <button class="btn btn-primary" id="start" type="button">开启报名</button>
        <button class="btn btn-danger" id="alldel" type="button">删除</button>
    </p>
    <?= GridView::widget([
            'id' => "myform",
            'pjax'=>false,
            'dataProvider' => $dataProvider,
            'filterModel' => $searchModel,
            'containerOptions'=>['style'=>'overflow: auto'], // only set when $responsive = false
            'headerRowOptions'=>['class'=>'kartik-sheet-style'],
            'filterRowOptions'=>['class'=>'filters'],
            'panel'=>[
                'heading'=>'<h3 class="panel-title"><i class="glyphicon glyphicon-globe"></i> 数据列表</h3>',
                'type'=>'default',
                'footer'=>false
            ],
            'toolbar' => [],
            'pager'=>[
                'options'=>['class'=>'hidden']//关闭自带分页
            ],
            'persistResize'=>false,

            'columns' => [
                [
                'class'=>'kartik\grid\CheckboxColumn',
                'headerOptions'=>['class'=>'my-table'],
                ],
                'id',
                'title',
                'summary',
                //'content',
                //'label_img',
                // 'beforeprompt',
                // 'duringprompt',
                // 'meetingdata',
                // 'is_valid',
                 //'created_at',
                [
                    'attribute' => 'created_at',
                    'format' => ['date', 'php:Y-m-d H:m:s'],
                ],
                // 'updated_at',
                // 'starttime',
                // 'endtime',
			   [
					'attribute' => 'enroll',
					'format' => 'html',
					'value' => function ($model) {
						if ($model->enroll === $model::IS_OPEN) {
							$class = 'label-success';
						} elseif ($model->enroll === $model::NO_OPEN) {
							$class = 'label-warning';
						} else {
							$class = 'label-danger';
						}
						return '<span class="label ' . $class . '">' . $model->IsopenLabel . '</span>';
					},
					'filterType'=>GridView::FILTER_SELECT2,
					'filter'=>Meeting::getArrayIsopen(),
					'filterWidgetOptions'=>[
						'pluginOptions'=>['allowClear'=>true],
					],
					'filterInputOptions'=>['placeholder'=>'全部'],
					'format'=>'raw'
				],
							   [
					'attribute' => 'is_pay',
					'format' => 'html',
					'value' => function ($model) {
						if ($model->is_pay === $model::IS_PAY) {
							$class = 'label-success';
						} elseif ($model->is_pay === $model::NO_PAY) {
							$class = 'label-warning';
						} else {
							$class = 'label-danger';
						}
						return '<span class="label ' . $class . '">' . $model->IspayLabel . '</span>';
					},
					'filterType'=>GridView::FILTER_SELECT2,
					'filter'=>Meeting::getArrayIspay(),
					'filterWidgetOptions'=>[
						'pluginOptions'=>['allowClear'=>true],
					],
					'filterInputOptions'=>['placeholder'=>'全部'],
					'format'=>'raw'
				],
                [
                    'class' => 'yii\grid\ActionColumn',
                    'header' => '操作', 
                    'template' => '{view}{update}{delete}{sign}{enroll}',
                    'headerOptions' => ['width' => '200'],
                    'buttons' => [
                        'view' => function ($url, $model, $key) {
                            return  Html::a('&nbsp;&nbsp;<span class="glyphicon glyphicon-eye-open" ><span class="classformat">查看</span></span>', $url, ['title' => '查看'] ) ;
                        },
                        'update' => function ($url, $model, $key) {
                            return Html::a('&nbsp;&nbsp;<span class="glyphicon glyphicon-pencil"><span class="classformat">修改</span></span>', $url, ['title' => '修改'] ) ;
                        },
                        'delete' => function ($url, $model, $key) {
                            return Html::a('&nbsp;&nbsp;<span class="glyphicon glyphicon-trash" ><span class="classformat">删除</span></span>', $url, [
                                'title' => '删除',
                                'data'=>[
                                    'confirm'=>'你确定要删除'.$model->title.'吗？',
                                    'method'=>'post'
                                ]
                            ] ) ;
                        },
                        'sign' => function ($url, $model, $key) {
                        return  Html::a('&nbsp;&nbsp;<span class="glyphicon glyphicon-eye-open" ><span class="classformat">签到名单</span></span>', $url, ['title' => '签到'] );
						},
						
						'enroll' => function ($url, $model, $key) {
                        return  Html::a('&nbsp;&nbsp;<span class="glyphicon glyphicon-eye-open" ><span class="classformat">报名信息</span></span>', ['/meetingenroll/index', 'id' => $model->id]);
                        },
                     ],
                ],
            ],
        ]); ?>
</div>
<?php $this->beginBlock('footer_scripts'); ?>
<script>
 $(document).ready(function(){
	bindqiyong("<?php echo Url::to(['meeting/start']);?>");
    bindtiyong("<?php echo Url::to(['meeting/stop']);?>");
    binddel("<?php echo Url::to(['meeting/alldelete']);?>");
});
</script>
<?php $this->endBlock(); ?>